<?php
require "admin/model/Model.php";
class TypeModel extends Model
{
	function __construct()
	{
		parent::__construct();
		$this->mod='foodtype';
	}
	function getTable()
	{
		$sql="select * from {$this->mod}";
		$data=$this->conn->query($sql);
		// var_dump($data);
		return $data;
	}
	function add($data)
	{

        $typename=$data['typename'];
        $sql = "insert into {$this->mod} values(null,'$typename')";
			  $result = $this->conn->query($sql);
			  return $result;
	}
	function getById($id)
	{
		$sql="select * from {$this->mod} where tid=".$id;
		$result=$this->conn->query($sql);
		return $result;	
	}
	function update($data)
  {
		    $id=trim($_POST['id']);
		    $typename=trim($_POST['typename']);
				$sql="update {$this->mod} set typename='{$typename}' where tid={$id}";
 
 				$result = $this->conn->query($sql);
				return $result;
	}
	function del($id)
  {
			$sql = "delete from {$this->mod} where tid=".$id;
			$result = $this->conn->query($sql);
			return $result;
	}
}
?>